

const sequelize = require('../db/sequelize')

const { DataTypes } = require('sequelize')

const Order = sequelize.define("nk_order", {
    user_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        comment: '用户ID'
    },
    address_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        comment: '地址id'
    },
    goods_info: {
        type: DataTypes.TEXT,
        allowNull: false,
        comment: '商品信息'
    },
    total: {
        type: DataTypes.DECIMAL(10, 2),
        allowNull: false,
        comment: '订单总金额'
    },
    oredr_number: {
        type: DataTypes.CHAR(20),
        allowNull: false,
        comment: '订单号'
    },
    state: {
        type: DataTypes.TINYINT,
        allowNull: false,
        defaultValue: false,
        comment: '订单状态(0未支付,1已支付,2已发货,3已签收,4取消)'
    }
}, {
    timestamps: true,//时间戳字段
    // paranoid: true,
},)

// 强制 删除并创建表
Order.sync({ focus: true })

module.exports = Order